package com.baizhi.service.impl;

import com.baizhi.dao.InvitationDao;
import com.baizhi.Invitation;
import com.baizhi.service.InvitationService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional  //该service下的实现类都提交事务
public class InvitationServiceImpl implements InvitationService {
    @Autowired
    private InvitationDao id;

    @Override
    public PageInfo<Invitation> page(int pageIndex,int pageSize) {
        PageHelper.startPage(pageIndex,pageSize);
        List<Invitation> invitations = id.selectList(null);
        return new PageInfo<>(invitations);
    }

    @Override
    public List<Invitation> selectWhere(String where) {
        QueryWrapper qw=new QueryWrapper();
        qw.like("title",where);
        System.out.println(where);
        if (where!=null){
            return id.selectList(qw);
        }
        return id.selectList(null);
    }
}
